<template>
  <h1>
    这是在登录页面引入的注册页面11
  </h1>
  <button @click="btn">操作</button>
  <ul>
    <li v-for="(item, index) in list" :key="index">{{ item }}</li>
  </ul>
  <span v-like="'yellow'">88</span>
  <craList></craList>
  <slot name="name2"></slot>
  <slot name="name1"></slot>
</template>

<script setup lang='ts' name="Register">
import { ref, inject, computed, provide } from 'vue'
import craList from '@/components/craList/index.vue';
import {loginStore} from '@/store/login';
import axios from 'axios'
import qs from 'qs';
// const url = '/api/index.php?store_id=1&store_type=6'
const _loginstore = loginStore()

const url = import.meta.env.VITE_BASE_API as string
console.log(url,import.meta.env)
async function fn(url: string) {
  const { data } = await axios[import.meta.env.MODE==='development'?'get':'post'](url, qs.stringify({
    
      module: 'app_pc',
      action: 'index',
      m: 'home',
      access_id: null,
      cid: null
    
  }))
  console.log(JSON.stringify(data), data)
}
fn(url)


// async function fn(url: string) {
//   const { data } = await axios.post(url, qs.stringify({
    
//       module: 'app_pc',
//       action: 'index',
//       m: 'home',
//       access_id: null,
//       cid: null
    
//   }))
//   console.log(JSON.stringify(data), data)
// }
// fn(url)
const list = reactive([
  '1'
])

let { proxy } = getCurrentInstance() as any
const btn = () => {
  // _loginstore.loginChangeState(2)
  _loginstore.$patch((state)=>{
    state.count++
    state.num++
  })
  proxy.$showMessage({
    msg: '我是帅哥',
    isShow: true,
    duration: 1000
  })
}
// const vLike = {
//   mounted (el:HTMLElement) {
//     el.className = 'sp'
//     el.onclick = ()=>{
//       console.log('你好吗')
//     }
//     console.log(el,'<<<<<<<<<<<<<')
//   }
// }
// interface binding { // 泛型约束
//   value: string
// }
type binding = {
  value: string
}
const vLike = <T extends binding>(el: HTMLElement, binding: T) => {
  console.log(binding, '???')
  el.style.color = binding.value
  el.onclick = () => {
    console.log('你好吗')
  }
}

// const count = computed(()=>{
//   return store.state.count
// })
// console.log(count,'count')
</script>
<script lang='ts'>
import {
  defineAsyncComponent,
  defineComponent, getCurrentInstance, nextTick, reactive
} from 'vue';
export default defineComponent({
  name: 'Register',
  setup() { }
})
</script>

<style scoped lang='scss'>
span {
  color: pink;
}

.sp {
  color: red;
}
</style>